<?php


namespace App\Services;

use App\Models\Config;
use Illuminate\Support\Facades\Cache;

// 配置服务
class ConfigService
{
    protected $cache_time = 864000;  // 缓存10天

    public function get($key, $tag = "")
    {
        $cacheKey = $tag . '-' . $key;
        $value = Cache::remember(
            $cacheKey,
            $this->cache_time,
            function () use ($key, $tag) {
                return Config::query()->where('tag', $tag)->where('key', $key)->first()->value;
            }
        );

        return $value;
    }

    public function check($key, $value, $tag = ""): bool
    {

    }
}